<#macro page table formId>
<script>
    function submitForm${formId}(pageSize, currentPage) {
        var searchForm = $('#' + '${formId}');
        searchForm.find("input[name=pageSize]").val(pageSize);
        searchForm.find("input[name=currentPage]").val(currentPage);
        searchForm.submit();
    }
</script>
<div class="tile-footer">
    <div class="row">
        <div class="col-sm-12 text-right">
            <ul class="pagination pagination-sm nomargin pagination-custom">
                <#if table.page.currentPage == 1>
                    <li><a href="javascript:;"><span class="disabled"><i class="fa fa-angle-double-left"></i></span></a>
                    </li>
                    <li class="active"><a href="javascript:;">1</a></li>
                <#else>
                    <li onclick="submitForm${formId}(${table.page.pageSize?c}, 1);"><a href="javascript:;"><span
                            class="pagepre"><i class="fa fa-angle-double-left"></i></span></a></li>
                    <li onclick="submitForm${formId}(${table.page.pageSize?c}, 1);"><a href="javascript:;">1</a></li>
                </#if>
                <#list 1.. ((table.page.totalPage - 4)/3 + 1) as group>
                    <#if 2 + 3*group gt table.page.currentPage>
                        <#assign currentGroup=group />
                        <#break>
                    </#if>
                </#list>
                <#if !currentGroup??>
                    <#assign currentGroup=(((table.page.totalPage - 4)/3)?int + 1)  />
                </#if>
                <#if currentGroup*3 - 1 gt 2>
                    <li class="paginItem"><a href="javascript:;">...</a></li>
                </#if>
                <#if table.page.totalPage gt 1>
                    <#list 2.. table.page.totalPage as index>
                        <#if (index gte currentGroup*3 - 2)  && (index lte currentGroup*3 + 2)>
                            <#if index == table.page.currentPage>
                                <li class="active"><a href="javascript:;">${index?c}</a></li>
                            <#else>
                                <li onclick="submitForm${formId}(${table.page.pageSize?c}, ${index?c});">
                                    <a href="javascript:;">${index?c}</a></li>
                            </#if>
                        </#if>
                    </#list>
                </#if>
                <#if currentGroup*3 + 2 lt table.page.totalPage - 1>
                    <li><a href="javascript:;">...</a></li>
                </#if>
                <#if table.page.totalPage gt currentGroup*3 + 2>
                    <#if table.page.currentPage == table.page.totalPage>
                        <li class="active"><a href="javascript:;">${table.page.totalPage?c}</a></li>
                    <#else>
                        <li
                            onclick="submitForm${formId}(${table.page.pageSize?c}, ${table.page.totalPage?c});"><a
                                href="javascript:;">${table.page.totalPage?c}</a></li>
                    </#if>
                </#if>
                <#if table.page.currentPage == table.page.totalPage || table.page.totalPage == 0>
                    <li><a href="javascript:;"><span class="disabled"><i
                            class="fa fa-angle-double-right"></i></span></a></li>
                <#else>
                    <li
                        onclick="submitForm${formId}(${table.page.pageSize?c}, ${table.page.totalPage?c});"><a
                            href="javascript:;"><span><i class="fa fa-angle-double-right"></i></span></a></li>
                </#if>
            </ul>
        </div>
    </div>
</div>
</#macro>
